public class Demo1 {
    public static void main(String[] args) throws InterruptedException{
        Thread t=new Thread(()->{
           for (int i=0;i<3;i++){
               System.out.println("这是线程t");
               try {
                   Thread.sleep(1000);
               } catch (InterruptedException e) {
                   e.printStackTrace();
               }
           }
            System.out.println("t线程结束");

        });
        t.start();

        Thread.sleep(4000);

        //让主线程，等待t线程
        System.out.println("main线程开始等待");
        t.join();
        System.out.println("main线程等待结束");

    }
}
